package com.ruoyi.house_sale.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.house_sale.domain.PaidType;
import com.ruoyi.house_sale.service.IPaidTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收款方式Controller
 * 
 * @author ruoyi
 * @date 2022-03-28
 */
@RestController
@RequestMapping("/house_sale/PaidType")
public class PaidTypeController extends BaseController
{
    @Autowired
    private IPaidTypeService paidTypeService;

    /**
     * 查询收款方式列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaidType paidType)
    {
        startPage();
        List<PaidType> list = paidTypeService.selectPaidTypeList(paidType);
        return getDataTable(list);
    }

    /**
     * 导出收款方式列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:export')")
    @Log(title = "收款方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaidType paidType)
    {
        List<PaidType> list = paidTypeService.selectPaidTypeList(paidType);
        ExcelUtil<PaidType> util = new ExcelUtil<PaidType>(PaidType.class);
        util.exportExcel(response, list, "收款方式数据");
    }

    /**
     * 获取收款方式详细信息
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:query')")
    @GetMapping(value = "/{paidtypeid}")
    public AjaxResult getInfo(@PathVariable("paidtypeid") Long paidtypeid)
    {
        return AjaxResult.success(paidTypeService.selectPaidTypeByPaidtypeid(paidtypeid));
    }

    /**
     * 新增收款方式
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:add')")
    @Log(title = "收款方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaidType paidType)
    {
        return toAjax(paidTypeService.insertPaidType(paidType));
    }

    /**
     * 修改收款方式
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:edit')")
    @Log(title = "收款方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaidType paidType)
    {
        return toAjax(paidTypeService.updatePaidType(paidType));
    }

    /**
     * 删除收款方式
     */
    @PreAuthorize("@ss.hasPermi('house_sale:PaidType:remove')")
    @Log(title = "收款方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paidtypeids}")
    public AjaxResult remove(@PathVariable Long[] paidtypeids)
    {
        return toAjax(paidTypeService.deletePaidTypeByPaidtypeids(paidtypeids));
    }
}
